﻿using MTQ.IBLL;
using MTQ.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MTQ.BLL
{
    public partial class Base_LocalService : BaseService<Base_Local>, IBase_LocalService
    {
        private static IList<Base_Local> listLanguage;
        private static IList<Base_Local> ListLanguage
        {
            get
            {
                if (listLanguage == null)
                {
                    Base_LocalService ls = new Base_LocalService();
                    ls.RefreshLanguage();
                }
                return listLanguage;
            }
        }

        public void RefreshLanguage()
        {
            listLanguage = _DbSession.Base_LocalRepository.LoadEntities(x => true).ToList();
            //listLanguage = new List<Base_Local>();
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Add", Local_zh_CN = "新增", Local_en_US = "Add" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "AddChild", Local_zh_CN = "添加下级", Local_en_US = "Add Items" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Edit", Local_zh_CN = "编辑", Local_en_US = "Edit" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Delete", Local_zh_CN = "删除", Local_en_US = "Delete" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Detail", Local_zh_CN = "详情", Local_en_US = "Detail" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Export", Local_zh_CN = "导出", Local_en_US = "Export" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Search", Local_zh_CN = "查 询", Local_en_US = "Search" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "SearchKey", Local_zh_CN = "查询关键字", Local_en_US = "Search" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "ProjectNumber", Local_zh_CN = "项目号", Local_en_US = "ProjectNumber" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "SaveSucceed", Local_zh_CN = "保存成功", Local_en_US = "Save Succeed" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "SaveFailed", Local_zh_CN = "保存失败", Local_en_US = "Save Failed" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "AreYouSure", Local_zh_CN = "确定删除吗", Local_en_US = "Are you sure to delete?" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "PostError", Local_zh_CN = "对不起出错了", Local_en_US = "Sorry,Error." });

            listLanguage.Add(new Base_Local() { Local_KeyWord = "Selected", Local_zh_CN = "已选择", Local_en_US = "Selected" });


            listLanguage.Add(new Base_Local() { Local_KeyWord = "ProjectInfo_FormelDUser", Local_zh_CN = "内部分配", Local_en_US = "FD Res." });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "ProjectInfo_CustomerUser", Local_zh_CN = "客户分配", Local_en_US = "Customer Res." });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Organization_UserNotNull", Local_zh_CN = "请选择用户", Local_en_US = "Select User ,Please!" });

            listLanguage.Add(new Base_Local() { Local_KeyWord = "Freezing", Local_zh_CN = "禁用", Local_en_US = "Inactive" });
            listLanguage.Add(new Base_Local() { Local_KeyWord = "Thawing", Local_zh_CN = "启用", Local_en_US = "Active" });

            //projectinfo_index

        }

        public static string GetWord(string key_word, string language)
        {
            Base_Local sl = ListLanguage.Where(x => x.Local_KeyWord == key_word).SingleOrDefault();
            if (sl != null)
            {
                string word = null;
                //switch (language)
                //{
                //    case "zh-CN":
                //        word = sl.Local_zh_CN;
                //        break;
                //    case "en_US":
                //        word = sl.Local_en_US;
                //        break;

                //    default:
                //        word = sl.Local_zh_CN;
                //        break;
                //}
                language = language.ToLower();

                if (language.IndexOf("cn") > -1)
                {
                    word = sl.Local_zh_CN;
                }
                else if (language.IndexOf("en") > -1)
                {
                    word = sl.Local_en_US;
                }
                else
                {
                    word = sl.Local_zh_CN;
                }

                return word;
            }
            return "";
        }
        public static void EmptyWord()
        {
            listLanguage = null;
        }


    }
}
